<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use kucha\ueditor\UEditor;

/* @var $this yii\web\View */
/* @var $model common\models\News */
/* @var $form yii\widgets\ActiveForm */
$this->registerCssFile('/uploadImg/css/fileinput.css');
$this->registerCssFile('/uploadImg/css/default.css');
$this->registerJsfile('/uploadImg/js/fileinput.js', [
    'depends' => 'yii\web\YiiAsset',
    'position' => \yii\web\View::POS_END
]);
?>

<div
	class="news-form">

    <?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'title',['options'=>['class'=>'col-xs-6 col-sm-6 col-md-6']])->textInput(['maxlength' => true]) ?>

    
    <?= $form->field($model, 'pid',['options'=>['class'=>'col-xs-2 col-sm-2 col-md-2']])->dropDownList(ArrayHelper::map($column, 'id', 'name')) ?>
    
    <?= $form->field($model, 'logo',['options'=>['class'=>'col-xs-2 col-sm-2 col-md-2']])->fileInput() ?>

    <?= $form->field($model, 'source',['options'=>['class'=>'col-xs-2 col-sm-2 col-md-2']])->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'message',['options'=>['class'=>'col-xs-12 col-sm-12 col-md-12']])->widget(UEditor::className()) ?>


    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
 <?php
    $logo = $model->logo != '' ? "'{$model->logo}'" : '';
    $js .= "$('#news-logo').fileinput({'showUpload':false,'initialPreview':[{$logo}],'msgSelected':'{n}个文件已上传','allowedFileExtensions' : ['jpg', 'png','gif','jpeg'],});
	";
    $this->registerJs($js);
    ?>
